Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-uglify

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-uglify

Minify files with UglifyJS.

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is gulp-uglify?

The gulp-uglify package is a Gulp plugin that minifies JavaScript files using UglifyJS. It helps in reducing the file size of JavaScript files by removing unnecessary characters, comments, and whitespace, making the code more efficient for production environments.

What are gulp-uglify's main functionalities?

Basic Minification

This feature allows you to minify JavaScript files. The code sample demonstrates how to create a Gulp task that takes JavaScript files from the 'src' directory, minifies them using gulp-uglify, and outputs the minified files to the 'dist' directory.

const gulp = require('gulp');
const uglify = require('gulp-uglify');

gulp.task('minify-js', function() {
  return gulp.src('src/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

Handling Errors

This feature demonstrates how to handle errors during the minification process. By using the 'gulp-plumber' package, you can prevent the Gulp process from stopping when an error occurs, allowing for smoother development workflows.

const gulp = require('gulp');
const uglify = require('gulp-uglify');
const plumber = require('gulp-plumber');

gulp.task('minify-js', function() {
  return gulp.src('src/*.js')
    .pipe(plumber())
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

Source Maps

This feature allows you to generate source maps for the minified JavaScript files. Source maps help in debugging by mapping the minified code back to the original source code. The code sample shows how to initialize source maps, minify the JavaScript files, and write the source maps to the output directory.

const gulp = require('gulp');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');

gulp.task('minify-js', function() {
  return gulp.src('src/*.js')
    .pipe(sourcemaps.init())
    .pipe(uglify())
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('dist'));
});

Other packages similar to gulp-uglify

Keywords

FAQs

Package last updated on 08 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc